<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.min.js"></script>
</head>
<body>
    <div></div>
    <script>
        // console.log(axios);

        let sutdentsAxios = axios.create()
        sutdentsAxios.interceptors.request.use(config=>{
            // 进度条
            NProgress.start();
            // 公共配置
            config.baseURL = 'http://localhost:3000';
            config.method = 'get';
            // 提交验证身份信息
            config.headers = {
                token:'1238hiasd98213hidshaida'
            }
            return config;
        })
        sutdentsAxios.interceptors.response.use(res=>{
            NProgress.done();
            return res
        })

        sutdentsAxios('/students').then(val=>{
            document.querySelector('div').innerHTML = val.data.map(item=>`<p>${item.name}</p>`).join('');
        });


    </script>
</body>
</html>